using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using NetWorkMsg;

namespace NetMsg.Card
{
    public enum TutorialProgress
    {
        // 基础教程
        Base,
        // 高级
        Advanced,
        // 挑战
        Challenge,
        LevelVI,
        LevelV,
        // 结束
        End,
    }
    
    public struct GetCardInfoQ : IServerCallbackable
    {
        
        public uint UnPackableId => 64;
        public uint PackableId => 83;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 83u);
        }
    }
    
    public class GetCardInfoP : IUnPackable
    {
        public BitArray Illustrated;
        public List<int> Deck;
        // 牌组数量
        public int GroupNum;
        // 当前的教程进度
        public TutorialProgress Progress;
        
        public const uint Sid = 64;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out Illustrated);
            UnPackAuxiliary.ReadUsAsIs(stream, out Deck);
            UnPackAuxiliary.Read(stream, out uint var0);
            GroupNum = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Progress = (TutorialProgress)var1;
        }
    }
    
    // 获得牌组
    public struct GetBrandGroupQ : IServerCallbackable
    {
        // 牌组索引
        public int Index;
        
        public uint UnPackableId => 65;
        public uint PackableId => 84;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 84u);
            PackAuxiliary.Write(stream, (uint)Index);
        }
    }
    
    public class GetBrandGroupP : IUnPackable
    {
        // 牌组
        public List<int> CardIds;
        
        public const uint Sid = 65;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.ReadUsAsIs(stream, out CardIds);
        }
    }
    
    // 设置牌组
    public class SetBrandGroupQ : IIdPackable
    {
        public int Index;
        public List<int> CardIds;
        
        public uint PackableId => 85;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 85u);
            PackAuxiliary.Write(stream, (uint)Index);
            PackAuxiliary.WriteIsAsUs(stream, CardIds);
        }
    }
    
    // 升级进度
    public struct UpgradeCardProgressQ : IServerCallbackable
    {
        // 选择的卡牌Id
        public int Pick;
        
        public uint UnPackableId => 66;
        public uint PackableId => 86;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 86u);
            PackAuxiliary.Write(stream, (uint)Pick);
        }
    }
    
    public class UpgradeCardProgressP : IUnPackable
    {
        // 新增加的牌
        public List<int> CardIds;
        
        public const uint Sid = 66;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.ReadUsAsIs(stream, out CardIds);
        }
    }
    
    public enum SignMatchResult
    {
        Success,
        // 匹配中/战斗中
        InMatch,
        // 体力不足
        NoStamina,
        // 没有对应的牌组
        NoGroup,
    }
    
    // 报名
    public struct SignMatchQ : IServerCallbackable
    {
        // 使用的牌组索引
        public int Index;
        // 使用电量
        public bool UseStamina;
        
        public uint UnPackableId => 67;
        public uint PackableId => 87;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 87u);
            PackAuxiliary.Write(stream, (uint)Index);
            PackAuxiliary.Write(stream, UseStamina);
        }
    }
    
    public struct SignMatchP : IUnPackable
    {
        public SignMatchResult Result;
        
        public const uint Sid = 67;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (SignMatchResult)var0;
        }
    }
    
    // 挑战
    public struct TutorialSignQ : IIdPackable
    {
        // 使用的配置Id
        public int CfgId;
        
        public uint PackableId => 88;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 88u);
            PackAuxiliary.Write(stream, (uint)CfgId);
        }
    }
    
    // 取消报名
    public struct CancelMatchSignQ : IIdPackable
    {
        
        public uint PackableId => 89;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 89u);
        }
    }
    
    // 选牌
    public class PickUpQ : IServerCallbackable
    {
        // 战场Id
        public int BattleId;
        // 选择的牌
        public List<int> Picks;
        // 选择后手牌
        public List<int> Deck;
        
        public uint UnPackableId => 68;
        public uint PackableId => 90;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 90u);
            PackAuxiliary.Write(stream, (uint)BattleId);
            PackAuxiliary.WriteIsAsUs(stream, Picks);
            PackAuxiliary.WriteIsAsUs(stream, Deck);
        }
    }
    
    public enum PickUpResult
    {
        // 成功
        Success,
        // 有卡组中没有的卡牌
        NotHasCard,
    }
    
    public struct PickUpP : IUnPackable
    {
        public PickUpResult Result;
        
        public const uint Sid = 68;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (PickUpResult)var0;
        }
    }
    
    public struct EndFightTurnQ : IIdPackable
    {
        // 战场Id
        public int BattleId;
        
        public uint PackableId => 91;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 91u);
            PackAuxiliary.Write(stream, (uint)BattleId);
        }
    }
    
    public struct PutOnQ : IServerCallbackable
    {
        // 战场Id
        public int BattleId;
        // 位置
        public int Pos;
        // 卡牌ID
        public int CardId;
        
        public uint UnPackableId => 69;
        public uint PackableId => 92;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 92u);
            PackAuxiliary.Write(stream, (uint)BattleId);
            PackAuxiliary.Write(stream, (uint)Pos);
            PackAuxiliary.Write(stream, (uint)CardId);
        }
    }
    
    public enum PutOnResult
    {
        // 成功
        Success,
        // 不是该玩家的回合
        NotInTurn,
        // 没有这个位置
        InvalidPos,
        // 手上没有这张卡
        NotHasCard,
        // 行动点不足
        NeedMoreCurrency,
        // 无法进行替换
        CanNotReplace,
        // 被禁锢
        BeConfine,
    }
    
    public struct PutOnP : IUnPackable
    {
        public PutOnResult Result;
        
        public const uint Sid = 69;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (PutOnResult)var0;
        }
    }
    
    public struct SurrenderQ : IIdPackable
    {
        // 战场Id
        public int BattleId;
        
        public uint PackableId => 93;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 93u);
            PackAuxiliary.Write(stream, (uint)BattleId);
        }
    }
    
    public struct SendEmojiQ : IIdPackable
    {
        // 战场Id
        public int BattleId;
        public int Index;
        
        public uint PackableId => 94;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 94u);
            PackAuxiliary.Write(stream, (uint)BattleId);
            PackAuxiliary.Write(stream, (uint)Index);
        }
    }
    
    public struct RecvEmojiP : IUnPackable
    {
        public int Index;
        
        public const uint Sid = 70;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Index = (int)var0;
        }
    }
    
    public enum UseSKillTime
    {
        Admission,
        SelfRound,
    }
    
    // 手动选择时的目标来源类型
    public enum AppointTargetType
    {
        // 先手方
        Offensive,
        // 后手方
        Defensive,
    }
    
    public class UseSkillQ : IIdPackable
    {
        // 战场Id
        public int BattleId;
        public int Pos;
        public UseSKillTime UseTime;
        // 手动选择时,第一个参数是AppointTargetType, 第二个参数是卡牌的位置或者行 列的序数
        public List<int> Args;
        
        public uint PackableId => 95;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 95u);
            PackAuxiliary.Write(stream, (uint)BattleId);
            PackAuxiliary.Write(stream, (uint)Pos);
            PackAuxiliary.Write(stream, (uint)UseTime);
            PackAuxiliary.WriteIsAsUs(stream, Args);
        }
    }
    
    // 客户端操作完成
    public struct ClientOpEndQ : IIdPackable
    {
        // 战场Id
        public int BattleId;
        
        public uint PackableId => 96;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 96u);
            PackAuxiliary.Write(stream, (uint)BattleId);
        }
    }
    
    // 商品信息 
    public class CommodityInfo : IUnPackable
    {
        // 配置Id
        public int CfgId;
        // 商品剩余数量
        public int Number;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            CfgId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Number = (int)var1;
        }
    }
    
    // 获得商店信息
    public struct GetStoreInfoQ : IServerCallbackable
    {
        
        public uint UnPackableId => 71;
        public uint PackableId => 97;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 97u);
        }
    }
    
    public class GetStoreInfoP : IUnPackable
    {
        // 决斗币
        public int Gold;
        // 剩余刷新次数
        public int RefreshTimes;
        public List<CommodityInfo> Infos;
        
        public const uint Sid = 71;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Gold = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            RefreshTimes = (int)var1;
            UnPackAuxiliary.Read(stream, out uint var2);
            Infos = new List<CommodityInfo>((int)var2);
            for(var i = 0; i < var2; ++i)
            {
                var var3 = new CommodityInfo();
                var3.UnPack(stream);
                Infos.Add(var3);
            }
        }
    }
    
    // 购买商品结果
    public enum BuyCommodityResult
    {
        Success,
        // 没有商品了
        NoMore,
        // 钱不够
        NoMoney,
    }
    
    // 购买商品
    public struct BuyCommodityQ : IServerCallbackable
    {
        public int CfgId;
        
        public uint UnPackableId => 72;
        public uint PackableId => 98;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 98u);
            PackAuxiliary.Write(stream, (uint)CfgId);
        }
    }
    
    public struct BuyCommodityP : IUnPackable
    {
        public BuyCommodityResult Result;
        
        public const uint Sid = 72;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (BuyCommodityResult)var0;
        }
    }
    
    // 刷新商店
    public struct RefreshStoreQ : IServerCallbackable
    {
        
        public uint UnPackableId => 73;
        public uint PackableId => 99;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 99u);
        }
    }
    
    public class RefreshStoreP : IUnPackable
    {
        // 数组长度为0就是刷新失败，理论上不存在
        public List<CommodityInfo> Infos;
        
        public const uint Sid = 73;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Infos = new List<CommodityInfo>((int)var0);
            for(var i = 0; i < var0; ++i)
            {
                var var1 = new CommodityInfo();
                var1.UnPack(stream);
                Infos.Add(var1);
            }
        }
    }
    
    // 可邮寄的卡牌信息
    public struct MailableCard : IUnPackable
    {
        // 卡牌Id
        public long CardId;
        // 配置Id
        public int CfgId;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out ulong var0);
            CardId = (long)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            CfgId = (int)var1;
        }
    }
    
    // 获得可邮寄的卡信息
    public struct GetMailableCardsQ : IServerCallbackable
    {
        
        public uint UnPackableId => 74;
        public uint PackableId => 100;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 100u);
        }
    }
    
    public class GetMailableCardsP : IUnPackable
    {
        public List<MailableCard> Cards;
        
        public const uint Sid = 74;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Cards = new List<MailableCard>((int)var0);
            for(var i = 0; i < var0; ++i)
            {
                var var1 = new MailableCard();
                var1.UnPack(stream);
                Cards.Add(var1);
            }
        }
    }
    
    // 通知获得新卡牌
    public class NoticeNewMailableCardP : IUnPackable
    {
        public MailableCard Card;
        
        public const uint Sid = 75;
        
        public void UnPack(MemoryStream stream)
        {
            Card = new MailableCard();
            Card.UnPack(stream);
        }
    }
    
    public enum CardEnum
    {
        GetCardInfoP,
        GetBrandGroupP,
        UpgradeCardProgressP,
        SignMatchP,
        PickUpP,
        PutOnP,
        RecvEmojiP,
        GetStoreInfoP,
        BuyCommodityP,
        RefreshStoreP,
        GetMailableCardsP,
        NoticeNewMailableCardP,
    }
}
